package com.niuwa.p2p.core.pdf.factory;


/**
 * PDF生成工厂
 * @ClassName: PDFFactory
 * @Description: PDF生成工厂，实现createProduct()方法
 * @author jsj
 */
public class ConcretePDFFactory extends PDFFactory {
	
	private static ConcretePDFFactory concretePDFFactory = null;
	
	/**
	 * 创建ConcretePDFFactory单例
	 */
	public static synchronized ConcretePDFFactory getInstance() {
		if (concretePDFFactory == null) {
			concretePDFFactory = new ConcretePDFFactory();
		}
		return concretePDFFactory;
	}
	
	/**
	 * 创建PDF生产类
	 */
    @SuppressWarnings("unchecked")
	public <T extends IPDFProduct> T createProduct(Class<T> c) {
      T product = null;
      try {
        product = (T) Class.forName(c.getName()).newInstance();
      } catch (Exception e) {
        e.printStackTrace();
      }
      return product;
    }
  } 